<?php

// 安装模块
// 创建模块的数据表

$sql = <<<EOT
 
DROP TABLE IF EXISTS `ims_knscy_system_admin`;
CREATE TABLE `ims_knscy_system_admin`
(
    `id`          bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    `auth_ids`    varchar(255)         DEFAULT NULL COMMENT '角色权限ID',
    `head_img`    varchar(255)         DEFAULT NULL COMMENT '头像',
    `username`    varchar(50) NOT NULL DEFAULT '' COMMENT '用户登录名',
    `password`    char(40)    NOT NULL DEFAULT '' COMMENT '用户登录密码',
    `phone`       varchar(16)          DEFAULT NULL COMMENT '联系手机号',
    `remark`      varchar(255)         DEFAULT '' COMMENT '备注说明',
    `login_num`   bigint(20) unsigned DEFAULT '0' COMMENT '登录次数',
    `sort`        int(11) DEFAULT '0' COMMENT '排序',
    `status`      tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '状态(0:禁用,1:启用,)',
    `create_time` int(11) DEFAULT NULL COMMENT '创建时间',
    `update_time` int(11) DEFAULT NULL COMMENT '更新时间',
    `delete_time` int(11) DEFAULT NULL COMMENT '删除时间',
    PRIMARY KEY (`id`),
    UNIQUE KEY `username` (`username`) USING BTREE,
    KEY           `phone` (`phone`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=COMPACT COMMENT='系统用户表';
 
INSERT INTO `ims_knscy_system_admin`
VALUES ('1', null, '/static/admin/images/head.jpg', 'admin', 'b1b4ebe1aaf205c0dec1b94607dca2c1e499cccb', 'admin', 'admin', '0', '0', '1', '1589454169', '1589476815', null);
 
DROP TABLE IF EXISTS `ims_knscy_system_auth`;
CREATE TABLE `ims_knscy_system_auth`
(
    `id`          bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    `title`       varchar(20) NOT NULL COMMENT '权限名称',
    `sort`        int(11) DEFAULT '0' COMMENT '排序',
    `status`      tinyint(1) unsigned DEFAULT '1' COMMENT '状态(1:禁用,2:启用)',
    `remark`      varchar(255) DEFAULT NULL COMMENT '备注说明',
    `create_time` int(11) DEFAULT NULL COMMENT '创建时间',
    `update_time` int(11) DEFAULT NULL COMMENT '更新时间',
    `delete_time` int(11) DEFAULT NULL COMMENT '删除时间',
    PRIMARY KEY (`id`),
    UNIQUE KEY `title` (`title`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=COMPACT COMMENT='系统权限表';
 
INSERT INTO `ims_knscy_system_auth`
VALUES ('1', '管理员', '1', '1', '测试管理员', '1588921753', '1589614331', null);
INSERT INTO `ims_knscy_system_auth`
VALUES ('6', '游客权限', '0', '1', '', '1588227513', '1589591751', '1589591751');
 
DROP TABLE IF EXISTS `ims_knscy_system_auth_node`;
CREATE TABLE `ims_knscy_system_auth_node`
(
    `id`      bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    `auth_id` bigint(20) unsigned DEFAULT NULL COMMENT '角色ID',
    `node_id` bigint(20) DEFAULT NULL COMMENT '节点ID',
    PRIMARY KEY (`id`),
    KEY       `index_system_auth_auth` (`auth_id`) USING BTREE,
    KEY       `index_system_auth_node` (`node_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=COMPACT COMMENT='角色与节点关系表';
 
INSERT INTO `ims_knscy_system_auth_node`
VALUES ('1', '6', '1');
INSERT INTO `ims_knscy_system_auth_node`
VALUES ('2', '6', '2');
INSERT INTO `ims_knscy_system_auth_node`
VALUES ('3', '6', '9');
INSERT INTO `ims_knscy_system_auth_node`
VALUES ('4', '6', '12');
INSERT INTO `ims_knscy_system_auth_node`
VALUES ('5', '6', '18');
INSERT INTO `ims_knscy_system_auth_node`
VALUES ('6', '6', '19');
INSERT INTO `ims_knscy_system_auth_node`
VALUES ('7', '6', '21');
INSERT INTO `ims_knscy_system_auth_node`
VALUES ('8', '6', '22');
INSERT INTO `ims_knscy_system_auth_node`
VALUES ('9', '6', '29');
INSERT INTO `ims_knscy_system_auth_node`
VALUES ('10', '6', '30');
INSERT INTO `ims_knscy_system_auth_node`
VALUES ('11', '6', '38');
INSERT INTO `ims_knscy_system_auth_node`
VALUES ('12', '6', '39');
INSERT INTO `ims_knscy_system_auth_node`
VALUES ('13', '6', '45');
INSERT INTO `ims_knscy_system_auth_node`
VALUES ('14', '6', '46');
INSERT INTO `ims_knscy_system_auth_node`
VALUES ('15', '6', '52');
INSERT INTO `ims_knscy_system_auth_node`
VALUES ('16', '6', '53');
 
DROP TABLE IF EXISTS `ims_knscy_system_config`;
CREATE TABLE `ims_knscy_system_config`
(
    `id`          int(10) unsigned NOT NULL AUTO_INCREMENT,
    `name`        varchar(30) NOT NULL DEFAULT '' COMMENT '变量名',
    `group`       varchar(30) NOT NULL DEFAULT '' COMMENT '分组',
    `value`       text COMMENT '变量值',
    `remark`      varchar(100)         DEFAULT '' COMMENT '备注信息',
    `sort`        int(10) DEFAULT '0',
    `create_time` int(11) DEFAULT NULL COMMENT '创建时间',
    `update_time` int(11) DEFAULT NULL COMMENT '更新时间',
    PRIMARY KEY (`id`),
    UNIQUE KEY `name` (`name`),
    KEY           `group` (`group`)
) ENGINE=InnoDB AUTO_INCREMENT=88 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=COMPACT COMMENT='系统配置表';
 
INSERT INTO `ims_knscy_system_config`
VALUES ('41', 'alisms_access_key_id', 'sms', '填你的', '阿里大于公钥', '0', null, null);
INSERT INTO `ims_knscy_system_config`
VALUES ('42', 'alisms_access_key_secret', 'sms', '填你的', '阿里大鱼私钥', '0', null, null);
INSERT INTO `ims_knscy_system_config`
VALUES ('55', 'upload_type', 'upload', 'local', '当前上传方式 （local,oss,cos）', '0', null, null);
INSERT INTO `ims_knscy_system_config`
VALUES ('56', 'upload_allow_ext', 'upload', 'doc,gif,ico,icon,jpg,mp3,mp4,p12,pem,png,rar,jpeg', '允许上传的文件类型', '0', null, null);
INSERT INTO `ims_knscy_system_config`
VALUES ('57', 'upload_allow_size', 'upload', '1024000', '允许上传的大小', '0', null, null);
INSERT INTO `ims_knscy_system_config`
VALUES ('58', 'upload_allow_mime', 'upload', 'image/gif,image/jpeg,video/x-msvideo,text/plain,image/png', '允许上传的文件mime', '0', null, null);
INSERT INTO `ims_knscy_system_config`
VALUES ('59', 'upload_allow_type', 'upload', 'local,oss,qnoss,cos', '可用的上传文件方式', '0', null, null);
INSERT INTO `ims_knscy_system_config`
VALUES ('60', 'oss_access_key_id', 'upload', '填你的', '阿里云oss公钥', '0', null, null);
INSERT INTO `ims_knscy_system_config`
VALUES ('61', 'oss_access_key_secret', 'upload', '填你的', '阿里云oss私钥', '0', null, null);
INSERT INTO `ims_knscy_system_config`
VALUES ('62', 'oss_endpoint', 'upload', '填你的', '阿里云oss数据中心', '0', null, null);
INSERT INTO `ims_knscy_system_config`
VALUES ('63', 'oss_bucket', 'upload', '填你的', '阿里云oss空间名称', '0', null, null);
INSERT INTO `ims_knscy_system_config`
VALUES ('64', 'oss_domain', 'upload', '填你的', '阿里云oss访问域名', '0', null, null);
INSERT INTO `ims_knscy_system_config`
VALUES ('65', 'logo_title', 'site', 'EasyAdmin', 'LOGO标题', '0', null, null);
INSERT INTO `ims_knscy_system_config`
VALUES ('66', 'logo_image', 'site', '/favicon.ico', 'logo图片', '0', null, null);
INSERT INTO `ims_knscy_system_config`
VALUES ('68', 'site_name', 'site', 'EasyAdmin后台系统', '站点名称', '0', null, null);
INSERT INTO `ims_knscy_system_config`
VALUES ('69', 'site_ico', 'site', '填你的', '浏览器图标', '0', null, null);
INSERT INTO `ims_knscy_system_config`
VALUES ('70', 'site_copyright', 'site', '填你的', '版权信息', '0', null, null);
INSERT INTO `ims_knscy_system_config`
VALUES ('71', 'site_beian', 'site', '填你的', '备案信息', '0', null, null);
INSERT INTO `ims_knscy_system_config`
VALUES ('72', 'site_version', 'site', '2.0.0', '版本信息', '0', null, null);
INSERT INTO `ims_knscy_system_config`
VALUES ('75', 'sms_type', 'sms', 'alisms', '短信类型', '0', null, null);
INSERT INTO `ims_knscy_system_config`
VALUES ('76', 'miniapp_appid', 'wechat', '填你的', '小程序公钥', '0', null, null);
INSERT INTO `ims_knscy_system_config`
VALUES ('77', 'miniapp_appsecret', 'wechat', '填你的', '小程序私钥', '0', null, null);
INSERT INTO `ims_knscy_system_config`
VALUES ('78', 'web_appid', 'wechat', '填你的', '公众号公钥', '0', null, null);
INSERT INTO `ims_knscy_system_config`
VALUES ('79', 'web_appsecret', 'wechat', '填你的', '公众号私钥', '0', null, null);
INSERT INTO `ims_knscy_system_config`
VALUES ('80', 'cos_secret_id', 'upload', '填你的', '腾讯云cos密钥', '0', null, null);
INSERT INTO `ims_knscy_system_config`
VALUES ('81', 'cos_secret_key', 'upload', '填你的', '腾讯云cos私钥', '0', null, null);
INSERT INTO `ims_knscy_system_config`
VALUES ('82', 'cos_region', 'upload', '填你的', '存储桶地域', '0', null, null);
INSERT INTO `ims_knscy_system_config`
VALUES ('83', 'cos_bucket', 'upload', '填你的', '存储桶名称', '0', null, null);
INSERT INTO `ims_knscy_system_config`
VALUES ('84', 'qnoss_access_key', 'upload', '填你的', '访问密钥', '0', null, null);
INSERT INTO `ims_knscy_system_config`
VALUES ('85', 'qnoss_secret_key', 'upload', '填你的', '安全密钥', '0', null, null);
INSERT INTO `ims_knscy_system_config`
VALUES ('86', 'qnoss_bucket', 'upload', '填你的', '存储空间', '0', null, null);
INSERT INTO `ims_knscy_system_config`
VALUES ('87', 'qnoss_domain', 'upload', '填你的', '访问域名', '0', null, null);
 
DROP TABLE IF EXISTS `ims_knscy_system_menu`;
CREATE TABLE `ims_knscy_system_menu`
(
    `id`          bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    `pid`         bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '父id',
    `title`       varchar(100) NOT NULL DEFAULT '' COMMENT '名称',
    `icon`        varchar(100) NOT NULL DEFAULT '' COMMENT '菜单图标',
    `href`        varchar(100) NOT NULL DEFAULT '' COMMENT '链接',
    `params`      varchar(500)          DEFAULT '' COMMENT '链接参数',
    `target`      varchar(20)  NOT NULL DEFAULT '_self' COMMENT '链接打开方式',
    `sort`        int(11) DEFAULT '0' COMMENT '菜单排序',
    `status`      tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '状态(0:禁用,1:启用)',
    `remark`      varchar(255)          DEFAULT NULL,
    `create_time` int(11) DEFAULT NULL COMMENT '创建时间',
    `update_time` int(11) DEFAULT NULL COMMENT '更新时间',
    `delete_time` int(11) DEFAULT NULL COMMENT '删除时间',
    PRIMARY KEY (`id`),
    KEY           `title` (`title`),
    KEY           `href` (`href`)
) ENGINE=InnoDB AUTO_INCREMENT=253 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=COMPACT COMMENT='系统菜单表';

 
INSERT INTO `ims_knscy_system_menu`
VALUES ('227', '99999999', '后台首页', 'fa fa-home', 'index/welcome', '', '_self', '0', '1', null, null, '1573120497', null);
INSERT INTO `ims_knscy_system_menu`
VALUES ('228', '0', '系统管理', 'fa fa-cog', '', '', '_self', '0', '1', '', null, '1588999529', null);
INSERT INTO `ims_knscy_system_menu`
VALUES ('234', '228', '菜单管理', 'fa fa-tree', 'system.menu/index', '', '_self', '10', '1', '', null, '1588228555', null);
INSERT INTO `ims_knscy_system_menu`
VALUES ('244', '228', '管理员管理', 'fa fa-user', 'system.admin/index', '', '_self', '12', '1', '', '1573185011', '1588228573', null);
INSERT INTO `ims_knscy_system_menu`
VALUES ('245', '228', '角色管理', 'fa fa-bitbucket-square', 'system.auth/index', '', '_self', '11', '1', '', '1573435877', '1588228634', null);
INSERT INTO `ims_knscy_system_menu`
VALUES ('246', '228', '节点管理', 'fa fa-list', 'system.node/index', '', '_self', '9', '1', '', '1573435919', '1588228648', null);
INSERT INTO `ims_knscy_system_menu`
VALUES ('247', '228', '配置管理', 'fa fa-asterisk', 'system.config/index', '', '_self', '8', '1', '', '1573457448', '1588228566', null);
INSERT INTO `ims_knscy_system_menu`
VALUES ('248', '228', '上传管理', 'fa fa-arrow-up', 'system.uploadfile/index', '', '_self', '0', '1', '', '1573542953', '1588228043', null);
INSERT INTO `ims_knscy_system_menu`
VALUES ('249', '0', '商城管理', 'fa fa-list', '', '', '_self', '0', '1', '', '1589439884', '1589439884', null);
INSERT INTO `ims_knscy_system_menu`
VALUES ('250', '249', '商品分类', 'fa fa-calendar-check-o', 'mall.cate/index', '', '_self', '0', '1', '', '1589439910', '1589439966', null);
INSERT INTO `ims_knscy_system_menu`
VALUES ('251', '249', '商品管理', 'fa fa-list', 'mall.goods/index', '', '_self', '0', '1', '', '1589439931', '1589439942', null);
INSERT INTO `ims_knscy_system_menu`
VALUES ('252', '228', '快捷入口', 'fa fa-list', 'system.quick/index', '', '_self', '0', '1', '', '1589623683', '1589623683', null);
INSERT INTO `ims_knscy_system_menu`
VALUES ('253', '228', '日志管理', 'fa fa-connectdevelop', 'system.log/index', '', '_self', '0', '1', '', '1589623684', '1589623684', null);
INSERT INTO `ims_knscy_system_menu`
VALUES ('254', '228', 'CURD可视化', 'fa fa fa-shower', 'system.curd_generate/index', '', '_self', '0', '1', '', '1589623684', '1589623684', null);

 
DROP TABLE IF EXISTS `ims_knscy_system_node`;
CREATE TABLE `ims_knscy_system_node`
(
    `id`          int(11) unsigned NOT NULL AUTO_INCREMENT,
    `node`        varchar(100) DEFAULT NULL COMMENT '节点代码',
    `title`       varchar(500) DEFAULT NULL COMMENT '节点标题',
    `type`        tinyint(1) DEFAULT '3' COMMENT '节点类型（1：控制器，2：节点）',
    `is_auth`     tinyint(1) unsigned DEFAULT '1' COMMENT '是否启动RBAC权限控制',
    `create_time` int(10) DEFAULT NULL COMMENT '创建时间',
    `update_time` int(10) DEFAULT NULL COMMENT '更新时间',
    PRIMARY KEY (`id`),
    KEY           `node` (`node`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=67 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=COMPACT COMMENT='系统节点表';

 
INSERT INTO `ims_knscy_system_node`
VALUES ('1', 'system.admin', '管理员管理', '1', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('2', 'system.admin/index', '列表', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('3', 'system.admin/add', '添加', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('4', 'system.admin/edit', '编辑', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('5', 'system.admin/password', '编辑', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('6', 'system.admin/delete', '删除', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('7', 'system.admin/modify', '属性修改', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('8', 'system.admin/export', '导出', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('9', 'system.auth', '角色权限管理', '1', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('10', 'system.auth/authorize', '授权', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('11', 'system.auth/saveAuthorize', '授权保存', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('12', 'system.auth/index', '列表', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('13', 'system.auth/add', '添加', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('14', 'system.auth/edit', '编辑', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('15', 'system.auth/delete', '删除', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('16', 'system.auth/export', '导出', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('17', 'system.auth/modify', '属性修改', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('18', 'system.config', '系统配置管理', '1', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('19', 'system.config/index', '列表', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('20', 'system.config/save', '保存', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('21', 'system.menu', '菜单管理', '1', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('22', 'system.menu/index', '列表', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('23', 'system.menu/add', '添加', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('24', 'system.menu/edit', '编辑', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('25', 'system.menu/delete', '删除', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('26', 'system.menu/modify', '属性修改', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('27', 'system.menu/getMenuTips', '添加菜单提示', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('28', 'system.menu/export', '导出', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('29', 'system.node', '系统节点管理', '1', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('30', 'system.node/index', '列表', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('31', 'system.node/refreshNode', '系统节点更新', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('32', 'system.node/clearNode', '清除失效节点', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('33', 'system.node/add', '添加', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('34', 'system.node/edit', '编辑', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('35', 'system.node/delete', '删除', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('36', 'system.node/export', '导出', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('37', 'system.node/modify', '属性修改', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('38', 'system.uploadfile', '上传文件管理', '1', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('39', 'system.uploadfile/index', '列表', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('40', 'system.uploadfile/add', '添加', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('41', 'system.uploadfile/edit', '编辑', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('42', 'system.uploadfile/delete', '删除', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('43', 'system.uploadfile/export', '导出', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('44', 'system.uploadfile/modify', '属性修改', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('45', 'mall.cate', '商品分类管理', '1', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('46', 'mall.cate/index', '列表', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('47', 'mall.cate/add', '添加', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('48', 'mall.cate/edit', '编辑', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('49', 'mall.cate/delete', '删除', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('50', 'mall.cate/export', '导出', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('51', 'mall.cate/modify', '属性修改', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('52', 'mall.goods', '商城商品管理', '1', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('53', 'mall.goods/index', '列表', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('54', 'mall.goods/stock', '入库', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('55', 'mall.goods/add', '添加', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('56', 'mall.goods/edit', '编辑', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('57', 'mall.goods/delete', '删除', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('58', 'mall.goods/export', '导出', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('59', 'mall.goods/modify', '属性修改', '2', '1', '1589580432', '1589580432');
INSERT INTO `ims_knscy_system_node`
VALUES ('60', 'system.quick', '快捷入口管理', '1', '1', '1589623188', '1589623188');
INSERT INTO `ims_knscy_system_node`
VALUES ('61', 'system.quick/index', '列表', '2', '1', '1589623188', '1589623188');
INSERT INTO `ims_knscy_system_node`
VALUES ('62', 'system.quick/add', '添加', '2', '1', '1589623188', '1589623188');
INSERT INTO `ims_knscy_system_node`
VALUES ('63', 'system.quick/edit', '编辑', '2', '1', '1589623188', '1589623188');
INSERT INTO `ims_knscy_system_node`
VALUES ('64', 'system.quick/delete', '删除', '2', '1', '1589623188', '1589623188');
INSERT INTO `ims_knscy_system_node`
VALUES ('65', 'system.quick/export', '导出', '2', '1', '1589623188', '1589623188');
INSERT INTO `ims_knscy_system_node`
VALUES ('66', 'system.quick/modify', '属性修改', '2', '1', '1589623188', '1589623188');
INSERT INTO `ims_knscy_system_node`
VALUES ('67', 'system.log', '操作日志管理', '1', '1', '1589623188', '1589623188');
INSERT INTO `ims_knscy_system_node`
VALUES ('68', 'system.log/index', '列表', '2', '1', '1589623188', '1589623188');
INSERT INTO `ims_knscy_system_node`
VALUES ('69', 'system.curd_generate', 'CURD可视化管理', '1', '1', '1589623188', '1589623188');
INSERT INTO `ims_knscy_system_node`
VALUES ('70', 'system.curd_generate/index', '列表', '2', '1', '1589623188', '1589623188');
INSERT INTO `ims_knscy_system_node`
VALUES ('71', 'system.curd_generate/save', '操作', '2', '1', '1589623188', '1589623188');
 
DROP TABLE IF EXISTS `ims_knscy_system_quick`;
CREATE TABLE `ims_knscy_system_quick`
(
    `id`          bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    `title`       varchar(20) NOT NULL COMMENT '快捷入口名称',
    `icon`        varchar(100) DEFAULT NULL COMMENT '图标',
    `href`        varchar(255) DEFAULT NULL COMMENT '快捷链接',
    `sort`        int(11) DEFAULT '0' COMMENT '排序',
    `status`      tinyint(1) unsigned DEFAULT '1' COMMENT '状态(1:禁用,2:启用)',
    `remark`      varchar(255) DEFAULT NULL COMMENT '备注说明',
    `create_time` int(11) DEFAULT NULL COMMENT '创建时间',
    `update_time` int(11) DEFAULT NULL COMMENT '更新时间',
    `delete_time` int(11) DEFAULT NULL COMMENT '删除时间',
    PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=COMPACT COMMENT='系统快捷入口表';

 
INSERT INTO `ims_knscy_system_quick`
VALUES ('1', '管理员管理', 'fa fa-user', 'system.admin/index', '0', '1', '', '1589624097', '1589624792', null);
INSERT INTO `ims_knscy_system_quick`
VALUES ('2', '角色管理', 'fa fa-bitbucket-square', 'system.auth/index', '0', '1', '', '1589624772', '1589624781', null);
INSERT INTO `ims_knscy_system_quick`
VALUES ('3', '菜单管理', 'fa fa-tree', 'system.menu/index', '0', '1', null, '1589624097', '1589624792', null);
INSERT INTO `ims_knscy_system_quick`
VALUES ('6', '节点管理', 'fa fa-list', 'system.node/index', '0', '1', null, '1589624772', '1589624781', null);
INSERT INTO `ims_knscy_system_quick`
VALUES ('7', '配置管理', 'fa fa-asterisk', 'system.config/index', '0', '1', null, '1589624097', '1589624792', null);
INSERT INTO `ims_knscy_system_quick`
VALUES ('8', '上传管理', 'fa fa-arrow-up', 'system.uploadfile/index', '0', '1', null, '1589624772', '1589624781', null);
INSERT INTO `ims_knscy_system_quick`
VALUES ('10', '商品分类', 'fa fa-calendar-check-o', 'mall.cate/index', '0', '1', null, '1589624097', '1589624792', null);
INSERT INTO `ims_knscy_system_quick`
VALUES ('11', '商品管理', 'fa fa-list', 'mall.goods/index', '0', '1', null, '1589624772', '1589624781', null);

 
DROP TABLE IF EXISTS `ims_knscy_system_uploadfile`;
CREATE TABLE `ims_knscy_system_uploadfile`
(
    `id`            int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID', 
    `upload_type`   varchar(20)  NOT NULL DEFAULT 'local' COMMENT '存储位置',
    `original_name` varchar(255)          DEFAULT '' COMMENT '文件原名',
    `url`           varchar(255) NOT NULL DEFAULT '' COMMENT '物理路径',
    `image_width`   varchar(30)  NOT NULL DEFAULT '' COMMENT '宽度',
    `image_height`  varchar(30)  NOT NULL DEFAULT '' COMMENT '高度',
    `image_type`    varchar(30)  NOT NULL DEFAULT '' COMMENT '图片类型',
    `image_frames`  int(10) unsigned NOT NULL DEFAULT 0 COMMENT '图片帧数',
    `mime_type`     varchar(100) NOT NULL DEFAULT '' COMMENT 'mime类型',
    `file_size`     int(10) unsigned NOT NULL DEFAULT 0 COMMENT '文件大小',
    `file_ext`      varchar(100)          DEFAULT '',
    `sha1`          varchar(40)  NOT NULL DEFAULT '' COMMENT '文件 sha1编码',
    `create_time`   int(10) DEFAULT NULL COMMENT '创建日期',
    `update_time`   int(10) DEFAULT NULL COMMENT '更新时间',
    `upload_time`   int(10) DEFAULT NULL COMMENT '上传时间',
    PRIMARY KEY (`id`),
    KEY             `upload_type` (`upload_type`)
) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=COMPACT COMMENT='上传文件表';

-- ----------------------------
-- Records of ims_knscy_system_uploadfile
-- ----------------------------
INSERT INTO `ims_knscy_system_uploadfile`
VALUES ('286', 'oss', 'image/jpeg', 'https://lxn-99php.oss-cn-shenzhen.aliyuncs.com/upload/20191111/0a6de1ac058ee134301501899b84ecb1.jpg', '', '', '', '0', 'image/jpeg', '0', 'jpg', '', 1573612437, null, null);
INSERT INTO `ims_knscy_system_uploadfile`
VALUES ('287', 'oss', 'image/jpeg', 'https://lxn-99php.oss-cn-shenzhen.aliyuncs.com/upload/20191111/46d7384f04a3bed331715e86a4095d15.jpg', '', '', '', '0', 'image/jpeg', '0', 'jpg', '', 1573612437, null, null);
INSERT INTO `ims_knscy_system_uploadfile`
VALUES ('288', 'oss', 'image/x-icon', 'https://lxn-99php.oss-cn-shenzhen.aliyuncs.com/upload/20191111/7d32671f4c1d1b01b0b28f45205763f9.ico', '', '', '', '0', 'image/x-icon', '0', 'ico', '', 1573612437, null, null);
INSERT INTO `ims_knscy_system_uploadfile`
VALUES ('289', 'oss', 'image/jpeg', 'https://lxn-99php.oss-cn-shenzhen.aliyuncs.com/upload/20191111/28cefa547f573a951bcdbbeb1396b06f.jpg', '', '', '', '0', 'image/jpeg', '0', 'jpg', '', 1573612437, null, null);
INSERT INTO `ims_knscy_system_uploadfile`
VALUES ('290', 'oss', 'image/jpeg', 'https://lxn-99php.oss-cn-shenzhen.aliyuncs.com/upload/20191111/2c412adf1b30c8be3a913e603c7b6e4a.jpg', '', '', '', '0', 'image/jpeg', '0', 'jpg', '', 1573612437, null, null);
INSERT INTO `ims_knscy_system_uploadfile`
VALUES ('296', 'cos', 'image/jpeg', 'https://easyadmin-1251997243.cos.ap-guangzhou.myqcloud.com/upload/20191114/2381eaf81208ac188fa994b6f2579953.jpg', '', '', '', '0', 'image/jpeg', '0', 'jpg', '', 1573612437, null, null);

ALTER TABLE ims_knscy_system_admin  ADD `wuid` int(10)  NULL DEFAULT '0' COMMENT '关联';

ALTER TABLE ims_knscy_system_admin  ADD `uniacid` int(10)  NULL DEFAULT '0' COMMENT '公众号id';
ALTER TABLE ims_knscy_system_menu  ADD `uniacid` int(10)  NULL DEFAULT '0' COMMENT '公众号id';

ALTER TABLE ims_knscy_system_auth  ADD `uniacid` int(10)  NULL DEFAULT '0' COMMENT '公众号id';
ALTER TABLE ims_knscy_system_auth_node  ADD `uniacid` int(10)  NULL DEFAULT '0' COMMENT '公众号id';
ALTER TABLE ims_knscy_system_config  ADD `uniacid` int(10)  NULL DEFAULT '0' COMMENT '公众号id';
ALTER TABLE ims_knscy_system_node  ADD `uniacid` int(10)  NULL DEFAULT '0' COMMENT '公众号id';
ALTER TABLE ims_knscy_system_quick  ADD `uniacid` int(10)  NULL DEFAULT '0' COMMENT '公众号id';
ALTER TABLE ims_knscy_system_uploadfile  ADD `uniacid` int(10)  NULL DEFAULT '0' COMMENT '公众号id';
ALTER TABLE ims_knscy_system_config DROP INDEX `name`, ADD UNIQUE `name` (`name`, `uniacid`) USING BTREE;


CREATE TABLE IF NOT EXISTS `ims_knscy_good_category`
(
    `id` int(11) NOT NULL  AUTO_INCREMENT COMMENT '分类ID',
    `uniacid` int(11) DEFAULT '0' COMMENT '公众号id',
    `title` varchar(255) NOT NULL COMMENT '分类名称',
    `level` int(11) NOT NULL DEFAULT '0' COMMENT '层级',
    `pid` int(11) DEFAULT NULL  DEFAULT '0' COMMENT '父ID', 
    `icon_image` varchar(255) DEFAULT NULL COMMENT '分类图标  {image}',
    `cover_image` varchar(255) DEFAULT NULL COMMENT '分类图片  {image}',
    `tags` varchar(255) DEFAULT NULL COMMENT '分类标签',  
    `status` tinyint(1) NOT NULL COMMENT '状态 {switch} (0:禁用,1:启用)',
    `sort` int(11) DEFAULT NULL COMMENT '排序 {sort}',
    `create_time` int(11) DEFAULT NULL COMMENT '创建时间',
    `update_time` int(11) DEFAULT NULL COMMENT '更新时间',    
    `delete_time` int(11) DEFAULT NULL COMMENT '删除时间',
    PRIMARY KEY (`id`) 
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
 
CREATE TABLE IF NOT EXISTS `ims_knscy_goods` (
  `id` int(12) unsigned NOT NULL AUTO_INCREMENT,
  `uniacid` int(11) DEFAULT '0' COMMENT '公众号id',
  `category_id` int(11) DEFAULT '0' COMMENT '分类ID',
  `title` varchar(255) NOT NULL COMMENT '商品名称',
  `sub_title` varchar(255) DEFAULT '' COMMENT '副标题',
  `logo` varchar(500) DEFAULT '' COMMENT '商品logo {image}',
  `images` text COMMENT '商品图片{images}',
   `relate_ticket_ids` varchar(500) DEFAULT '' COMMENT '关联门票ids',
   `relate_card_ids` varchar(500) DEFAULT '' COMMENT '关联卡券ids',
  `description` text COMMENT '商品描述', 
  `sales` int(11) DEFAULT '0' COMMENT '销量',
  `virtual_sales` int(11) DEFAULT '0' COMMENT '虚拟销量', 
  `sort` int(11) DEFAULT '0' COMMENT '排序',
  `status` tinyint(1) unsigned DEFAULT '1' COMMENT '状态(1:禁用,2:启用)', 
  `create_time` int(11) DEFAULT NULL COMMENT '创建时间',
  `update_time` int(11) DEFAULT NULL COMMENT '更新时间',
  `delete_time` int(11) DEFAULT NULL COMMENT '删除时间',
  PRIMARY KEY (`id`),
  KEY `category_id` (`category_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8  COMMENT='商品列表';

CREATE TABLE IF NOT EXISTS `ims_knscy_good_ticket` (
    `id` int(11) unsigned NOT NULL   AUTO_INCREMENT  COMMENT 'ID',
    `good_id` int(11) DEFAULT '0' COMMENT '商品id',
    `ticket_id` int(11) DEFAULT '0' COMMENT '门票id',
      PRIMARY KEY (`id`),
      KEY `good_id` (`good_id`)
 ) ENGINE=InnoDB  DEFAULT CHARSET=utf8  COMMENT='商品和门票关系表';

CREATE TABLE IF NOT EXISTS `ims_knscy_users` (
    `id` int(11) unsigned NOT NULL   AUTO_INCREMENT  COMMENT 'ID',
    `uniacid` int(11) DEFAULT '0' COMMENT '公众号id',
    `mobile` varchar(20) DEFAULT NULL COMMENT '手机号码',
    `head_img` varchar(255) DEFAULT NULL COMMENT '头像 {image}',
    `nickname` varchar(200) DEFAULT NULL COMMENT '昵称',
    `username` varchar(50) NOT NULL COMMENT '用户名',
    `password` varchar(50) DEFAULT NULL COMMENT '登录密码',
    `remark` varchar(255) DEFAULT NULL COMMENT '备注说明',
    `ishexiao`  tinyint(1) DEFAULT 0 COMMENT '核销员{radio} (0:否,1:是)',
    `login_num` int(11) DEFAULT NULL COMMENT '登录次数',
    `last_login_ip` varchar(255) DEFAULT NULL COMMENT '上一次登录ip',
    `last_login_time` int(11)  DEFAULT 0 COMMENT '最后登录时间',
    `sort` int(11) NOT NULL DEFAULT '0' COMMENT '排序 {sort}',
    `status` tinyint(4) DEFAULT '1' COMMENT '状态 {radio} (0:禁用,1:启用)',
    `create_time` int(11)  DEFAULT NULL COMMENT '创建时间',
    `update_time` int(11)  DEFAULT NULL,
    `delete_time` datetime DEFAULT NULL,
    PRIMARY KEY (`id`) ,
    KEY `uniacid` (`uniacid`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8  COMMENT='用户表';

 
  CREATE TABLE IF NOT EXISTS `ims_knscy_user_bind` (
    `id` int(11) unsigned NOT NULL   AUTO_INCREMENT  COMMENT 'ID',
    `uniacid` int(11) DEFAULT '0' COMMENT '公众号id',
    `user_id` int(11)  NOT NULL  COMMENT '关联表users',
    `openid`  varchar(100) DEFAULT NULL COMMENT '公众号openid',
    `status` tinyint(4) DEFAULT '1' COMMENT '状态 {radio} (0:禁用,1:启用)',
    `create_time` int(11)  DEFAULT NULL COMMENT '创建时间',
    `token` varchar(255) DEFAULT NULL COMMENT '登陆的token',
    `bind_type` varchar(25) DEFAULT NULL COMMENT '綁定的手手机号 ',
    `update_time` int(11)  DEFAULT NULL,
    `delete_time` datetime DEFAULT NULL,
    PRIMARY KEY (`id`) ,
    KEY `uniacid` (`uniacid`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8   COMMENT='用户表';

  CREATE TABLE IF NOT EXISTS `ims_knscy_tickets` (
    `id` int(11) unsigned NOT NULL   AUTO_INCREMENT  COMMENT 'ID',
    `uniacid` int(11) DEFAULT '0' COMMENT '公众号id',
    `title` varchar(255)  NOT NULL  COMMENT '标题名称',
    `sub_title` varchar(255)  NOT NULL  COMMENT '副标题', 
    `price` decimal(10,2) DEFAULT '0.00' COMMENT '销售价格',
    `orgin_price` decimal(10,2) DEFAULT '0.00' COMMENT '原价格',
    `sale_count` int(11) DEFAULT '0' COMMENT '销量',
    `virtual_sale_count` int(11) DEFAULT '0' COMMENT '虚拟销量',
    `ticket_type` tinyint(1) DEFAULT '1' COMMENT '类型1=门票2=次卡3=年卡',
    `use_count` int(11) DEFAULT '0' COMMENT '次卡次数',
    `min_time` int(11) DEFAULT '0' COMMENT '至少提前几小时预订', 
    `can_refund` tinyint(1) unsigned DEFAULT '1' COMMENT '是否可退 {radio} (0:否,1:是)',
    `need_check` tinyint(1) unsigned DEFAULT '0' COMMENT '是否需换票 {radio} (0:否,1:是)',
    `stock` int(11) DEFAULT '0' COMMENT '库存', 
    `sort` int(11) DEFAULT '0' COMMENT '排序',
    `status` tinyint(1) unsigned DEFAULT '1' COMMENT '状态 {radio} (0:禁用,1:启用)',
    `remark` text DEFAULT NULL COMMENT '备注说明',
    `create_time` int(11) DEFAULT NULL COMMENT '创建时间',
    `update_time` int(11) DEFAULT NULL COMMENT '更新时间',
    `delete_time` int(11) DEFAULT NULL COMMENT '删除时间',
    PRIMARY KEY (`id`) ,
    KEY `uniacid` (`uniacid`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8   COMMENT='门票表';

  CREATE TABLE IF NOT EXISTS `ims_knscy_tickets_price` (
    `id` int(11) unsigned NOT NULL   AUTO_INCREMENT  COMMENT 'ID',
    `type_id` int(11) NOT NULL DEFAULT '0'  COMMENT '类型{radio} (1:按时间段,2:按周重复,3:按日期)',
    `uniacid` int(11) DEFAULT '0' COMMENT '公众号id',
    `ticket_id` int(11) NOT NULL  COMMENT '标题名称', 
    `price` decimal(10,2) DEFAULT '0.00' COMMENT '销售价格',
    `content` varchar(255)  DEFAULT NULL COMMENT '内容',    
    `sort` int(11) DEFAULT '0' COMMENT '排序',
    `status` tinyint(1) unsigned DEFAULT '1' COMMENT '状态 {radio} (0:禁用,1:启用)',
    `create_time` int(11) DEFAULT NULL COMMENT '创建时间',
    `update_time` int(11) DEFAULT NULL COMMENT '更新时间',
    `delete_time` int(11) DEFAULT NULL COMMENT '删除时间',
    PRIMARY KEY (`id`) ,
    KEY `uniacid` (`uniacid`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8   COMMENT='门票价格';


  CREATE TABLE IF NOT EXISTS `ims_knscy_infos` (
    `id` int(11) unsigned NOT NULL   AUTO_INCREMENT  COMMENT 'ID',
    `type_id` int(11) NOT NULL DEFAULT '0'  COMMENT '类型{radio} (0:自定义,1:购买须知,2:限购说明,3:使用说明,4:费用说明,5:产品详情,6:改退规则,7:发票说明,8:入园须知)',
    `uniacid` int(11) DEFAULT '0' COMMENT '公众号id',
    `title` varchar(255)  NOT NULL  COMMENT '标题名称', 
    `content` text DEFAULT NULL COMMENT '内容',    
    `sort` int(11) DEFAULT '0' COMMENT '排序',
    `status` tinyint(1) unsigned DEFAULT '1' COMMENT '状态 {radio} (0:禁用,1:启用)',
    `create_time` int(11) DEFAULT NULL COMMENT '创建时间',
    `update_time` int(11) DEFAULT NULL COMMENT '更新时间',
    `delete_time` int(11) DEFAULT NULL COMMENT '删除时间',
    PRIMARY KEY (`id`) ,
    KEY `uniacid` (`uniacid`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8  COMMENT='门票文案';

  CREATE TABLE IF NOT EXISTS `ims_knscy_banner` (
    `id` int(11) unsigned NOT NULL   AUTO_INCREMENT  COMMENT 'ID',
    `type_id` int(11) NOT NULL DEFAULT '0'  COMMENT '类型{radio} (0:大图轮播,1:首页导航,2:我的中心,3:其他 )',
    `uniacid` int(11) DEFAULT '0' COMMENT '公众号id',
    `title` varchar(255)  NOT NULL  COMMENT '标题名称', 
    `thumb` varchar(255) DEFAULT NULL COMMENT '图片 {image}', 
    `thumb_hover` varchar(255) DEFAULT NULL COMMENT '图片选中 {image}', 
    `link_type` tinyint(1) DEFAULT '0' COMMENT 'URL类型{radio} (0:网页URL,1:小程序URL)', 
    `open_url`  varchar(255)  DEFAULT NULL COMMENT '链接URL',    
    `sort` int(11) DEFAULT '0' COMMENT '排序',
    `gid` int(11) NOT NULL DEFAULT '0'  COMMENT '类型{radio}(0:幻灯片,1:菜单)',
    `status` tinyint(1) unsigned DEFAULT '1' COMMENT '状态 {radio} (0:禁用,1:启用)',
    `create_time` int(11) DEFAULT NULL COMMENT '创建时间',
    `update_time` int(11) DEFAULT NULL COMMENT '更新时间',
    `delete_time` int(11) DEFAULT NULL COMMENT '删除时间',
    PRIMARY KEY (`id`) ,
    KEY `uniacid` (`uniacid`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8  COMMENT='幻灯片图';

  CREATE TABLE IF NOT EXISTS `ims_knscy_pages` (
    `id` int(11) NOT NULL   AUTO_INCREMENT  COMMENT 'ID', 
    `uniacid` int(11) DEFAULT '0' COMMENT '公众号id',
    `cate_id` int(11) DEFAULT '0' COMMENT '分类',
    `title` varchar(255)  NOT NULL  COMMENT '标题名称', 
    `sub_title` varchar(255)  NOT NULL  COMMENT '副标题', 
    `cover` varchar(255) DEFAULT NULL COMMENT '图片 {image}', 
    `content` longtext DEFAULT NULL COMMENT '内容',    
    `sort` int(11) DEFAULT '0' COMMENT '排序',
    `status` tinyint(1) unsigned DEFAULT '1' COMMENT '状态 {radio} (0:禁用,1:启用)',
    `create_time` int(11) DEFAULT NULL COMMENT '创建时间',
    `update_time` int(11) DEFAULT NULL COMMENT '更新时间',
    `delete_time` int(11) DEFAULT NULL COMMENT '删除时间',
    PRIMARY KEY (`id`) ,
    KEY `uniacid` (`uniacid`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8  COMMENT='单页文章';
 

  CREATE TABLE IF NOT EXISTS `ims_knscy_user_people` (
    `id` int(11) NOT NULL   AUTO_INCREMENT  COMMENT 'ID', 
    `uniacid` int(11) DEFAULT '0' COMMENT '公众号id',
    `user_id` int(11) DEFAULT '0' COMMENT '所属用户id',
    `first_name` varchar(11) DEFAULT '' COMMENT '姓氏',
    `name` varchar(35)   DEFAULT ''  COMMENT '名称', 
    `mobile` varchar(20)   DEFAULT ''  COMMENT '手机号',  
    `identity_type` varchar(20) DEFAULT '' COMMENT '证件类型', 
    `identity` varchar(45)  DEFAULT ''  COMMENT '证件号码', 
    `sort` int(11) DEFAULT '0' COMMENT '排序',
    `status` tinyint(1) unsigned DEFAULT '1' COMMENT '状态 {radio} (0:禁用,1:启用)',
    `create_time` int(11) DEFAULT NULL COMMENT '创建时间',
    `update_time` int(11) DEFAULT NULL COMMENT '更新时间',
    `delete_time` int(11) DEFAULT NULL COMMENT '删除时间',
    PRIMARY KEY (`id`) ,
    KEY `uniacid` (`uniacid`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8  COMMENT='客户出行人信息';
  
 
CREATE TABLE IF NOT EXISTS `ims_knscy_orders` (
  `id` int(12) unsigned NOT NULL AUTO_INCREMENT,
  `order_no` varchar(25) DEFAULT NULL COMMENT '订单编号',
  `openid` varchar(45) DEFAULT NULL COMMENT '用户openid',
  `uniacid` int(12) DEFAULT '0' COMMENT '公众号ID',
  `user_id` int(12) DEFAULT '0' COMMENT '用户ID',
  `order_money` decimal(10,2) DEFAULT '0'  COMMENT '订单金额',
  `pay_money` decimal(10,2) DEFAULT '0'  COMMENT '支付金额',
  `discount_money` decimal(10,2) DEFAULT '0'  COMMENT '折扣金额',
  `pay_type` int(12) DEFAULT '0'  COMMENT '支付方式 1=微信支付',
  `pay_status` int(12) DEFAULT '0' COMMENT '支付状态 {radio} (0:未支付,1:已支付,9支付失败)',
  `order_status` int(12) DEFAULT '0'  COMMENT '订单状态',
  `status_label` varchar(25) DEFAULT 'unpaid'  COMMENT '订单状态unpaid,payment,processing,completed',
  `good_id` int(12) NOT NULL DEFAULT '0' COMMENT '商品ID', 
  `good_title`  varchar(255)   NULL DEFAULT '' COMMENT '商品标题', 
  `ticket_id` int(12) NOT NULL DEFAULT '0' COMMENT '门票ID',
  `ticket_type` tinyint(1)  DEFAULT '1' COMMENT '门票类型1=门票2次卡3年卡',  
  `remark` varchar(255) DEFAULT NULL  COMMENT '下单人备注信息', 
  `is_refund` tinyint(1) unsigned DEFAULT '0' COMMENT '1=已退款',
  `can_refund` tinyint(1) unsigned DEFAULT '1' COMMENT '是否可退 {radio} (0:否,1:是)',
  `need_check` tinyint(1) unsigned DEFAULT '0' COMMENT '是否需换票 {radio} (0:否,1:是)',
    `sort` int(11) DEFAULT '0' COMMENT '排序',
    `status` tinyint(1) unsigned DEFAULT '1' COMMENT '状态 {radio} (0:禁用,1:启用)',
    `create_time` int(11) DEFAULT NULL COMMENT '创建时间',
    `update_time` int(11) DEFAULT NULL COMMENT '更新时间',
    `delete_time` int(11) DEFAULT NULL COMMENT '删除时间',
  PRIMARY KEY (`id`),
   key `order_no` (`order_no`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8  COMMENT='订单表';

 
CREATE TABLE   IF NOT EXISTS `ims_knscy_order_ticket` (
  `id` int(12) unsigned NOT NULL AUTO_INCREMENT,
  `order_id` int(12) NOT NULL,
  `order_no` varchar(25) DEFAULT NULL COMMENT '订单编号',
  `uniacid` int(12) NOT NULL, 
  `ticket_id` int(12) NOT NULL DEFAULT '0' COMMENT '门票ID', 
  `ticket_title` varchar(255) NOT NULL  DEFAULT '' COMMENT '门票标题',  
  `ticket_subtitle` varchar(255) NOT NULL DEFAULT '' COMMENT '门票副标题',     
  `good_id` int(12) NOT NULL,
  `good_title`  varchar(255)   NULL DEFAULT '' COMMENT '商品标题', 
  `ticket_type` tinyint(1)  DEFAULT '1' COMMENT '门票类型1=门票2次卡3年卡', 
  `ticket_json` text COMMENT '门票数据',
  `select_day` varchar(255) DEFAULT '' COMMENT '出游时间',
  `buy_num` int(12) NOT NULL DEFAULT '0'  COMMENT '门票数量',
  `price` decimal(10,2) NOT NULL DEFAULT '0.00'  COMMENT '门票单价',
  `people_ids` varchar(255) DEFAULT '' COMMENT '出行人ids', 
  `people_json` text COMMENT '出行人数据',
   `sort` int(11) DEFAULT '0' COMMENT '排序',
    `status` tinyint(1) unsigned DEFAULT '1' COMMENT '状态 {radio} (0:禁用,1:启用)',
    `create_time` int(11) DEFAULT NULL COMMENT '创建时间',
    `update_time` int(11) DEFAULT NULL COMMENT '更新时间',
    `delete_time` int(11) DEFAULT NULL COMMENT '删除时间',
  PRIMARY KEY (`id`),
   key `order_no` (`order_no`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8  COMMENT='订单的门票表';

CREATE TABLE   IF NOT EXISTS `ims_knscy_ticket_out` (
  `id` int(12) unsigned NOT NULL AUTO_INCREMENT, 
  `order_no` varchar(25) DEFAULT NULL COMMENT '订单编号',
  `ticket_sn` varchar(25) DEFAULT NULL COMMENT '票务编号',
  `uniacid` int(12) NOT NULL DEFAULT '0', 
  `user_id` int(12) DEFAULT '0' COMMENT '用户ID',
  `ticket_id` int(12) NOT NULL DEFAULT '0' COMMENT '门票ID', 
  `ticket_title` varchar(255) NOT NULL  DEFAULT '' COMMENT '门票标题',  
  `ticket_subtitle` varchar(255) NOT NULL DEFAULT '' COMMENT '门票副标题',     
  `ticket_type` tinyint(1)  DEFAULT '1' COMMENT '门票类型1=门票,2=次卡,3=年卡,4=凭证',  
  `select_day` varchar(255) DEFAULT '' COMMENT '出游时间',
  `total_count` int(6) NOT NULL DEFAULT '0'  COMMENT '总次数',
  `use_count` int(6) NOT NULL DEFAULT '0'  COMMENT '已用次数',
  `orgin_price` decimal(10,2) NOT NULL DEFAULT '0.00'  COMMENT '原单价',
  `price` decimal(10,2) NOT NULL DEFAULT '0.00'  COMMENT '门票单价', 
  `people_info` varchar(255) DEFAULT NULL COMMENT '出行人数据',
  `is_end`  tinyint(1) unsigned DEFAULT '0' COMMENT '启用 {radio} (0:待用,1:用完)',
  `start_time` dateTime DEFAULT NULL COMMENT '启用时间',
  `end_time` dateTime DEFAULT NULL COMMENT '结束时间',
  `last_use_time` dateTime DEFAULT NULL COMMENT '最后使用时间',
   `sort` int(11) DEFAULT '0' COMMENT '排序',
    `status` tinyint(1) unsigned DEFAULT '1' COMMENT '状态 {radio} (0:禁用,1:启用)',
    `create_time` int(11) DEFAULT NULL COMMENT '创建时间',
    `update_time` int(11) DEFAULT NULL COMMENT '更新时间',
    `delete_time` int(11) DEFAULT NULL COMMENT '删除时间',
  PRIMARY KEY (`id`),
   key `order_no` (`order_no`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8  COMMENT='出票信息';

CREATE TABLE IF NOT EXISTS `ims_knscy_ticket_out_logs` (
  `id` int(12) NOT NULL AUTO_INCREMENT,
   `uniacid` int(12) DEFAULT NULL,
   `ticket_sn` varchar(25) DEFAULT NULL COMMENT '票务编号', 
   `ticket_type` tinyint(1)  DEFAULT '1' COMMENT '门票类型1=门票2次卡3年卡',  
   `hx_user_id` int(11) DEFAULT '0'  COMMENT '核销人的用户ID',
    `admin_id` int(11) DEFAULT '0'  COMMENT '管理员ID',
    `tag` varchar(255) DEFAULT NULL  COMMENT '日志标示' , 
    `create_time` int(11) DEFAULT NULL COMMENT '创建时间',
    `update_time` int(11) DEFAULT NULL COMMENT '更新时间',
    `delete_time` int(11) DEFAULT NULL COMMENT '删除时间', 
  PRIMARY KEY (`id`),
  key `uniacid` (`uniacid`),
  key `ticket_sn` (`ticket_sn`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8  COMMENT='票和卡的日志表';

 
CREATE TABLE IF NOT EXISTS `ims_knscy_order_logs` (
  `id` int(12) NOT NULL AUTO_INCREMENT,
   `uniacid` int(12) DEFAULT NULL,
   `order_no` varchar(25) DEFAULT NULL COMMENT '订单编号',
   `order_id` int(11) DEFAULT '0'  COMMENT '订单id',
    `admin_id` int(11) DEFAULT '0'  COMMENT '管理员ID',
   `tag`  varchar(45) DEFAULT NULL  COMMENT '日志标示' ,
    `content` text,
    `create_time` int(11) DEFAULT NULL COMMENT '创建时间',
    `update_time` int(11) DEFAULT NULL COMMENT '更新时间',
    `delete_time` int(11) DEFAULT NULL COMMENT '删除时间', 
  PRIMARY KEY (`id`),
  key `tag` (`tag`),
  key `order_no` (`order_no`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8  COMMENT='订单日志表';

CREATE TABLE IF NOT EXISTS `ims_knscy_redpack` (
   `id` int(12) NOT NULL AUTO_INCREMENT,
   `uniacid` int(12) DEFAULT NULL,
   `title` varchar(255) NOT NULL  DEFAULT '' COMMENT '券标题',  
   `subtitle` varchar(255) NOT NULL DEFAULT '' COMMENT '副标题',  
    `tag` varchar(255) DEFAULT NULL  COMMENT '标签' ,
   `redpack_no` varchar(25) DEFAULT NULL COMMENT '优惠券的编号', 
   `redpack_type` tinyint(1)  DEFAULT '1' COMMENT '类型{radio} (1:优惠券,2:线下凭证)',  
   `limit_time` int(11) DEFAULT '0'  COMMENT '有效期天数', 
   `discount`  decimal(10,2) DEFAULT '0.00'  COMMENT '折扣金额' ,
   `start_time` datetime DEFAULT NULL COMMENT '开始时间{date}(datetime)',
    `end_time`  datetime DEFAULT NULL COMMENT '结束时间{date}(datetime)',
    `total_num` int(5) DEFAULT 0  COMMENT '发放数量' ,
    `describe` text COMMENT '使用说明',
    `sort` int(11) DEFAULT '0' COMMENT '排序',
    `status` tinyint(1) unsigned DEFAULT '1' COMMENT '状态 {radio} (0:禁用,1:启用)', 
    `create_time` int(11) DEFAULT NULL COMMENT '创建时间',
    `update_time` int(11) DEFAULT NULL COMMENT '更新时间',
    `delete_time` int(11) DEFAULT NULL COMMENT '删除时间', 
  PRIMARY KEY (`id`),
  key `uniacid` (`uniacid`),
  key `redpack_no` (`redpack_no`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8  COMMENT='优惠券和线下凭证';

CREATE TABLE IF NOT EXISTS `ims_knscy_redpack_agent` (
  `id` int(12) NOT NULL AUTO_INCREMENT,
   `uniacid` int(12) DEFAULT NULL,
   `redpack_no` varchar(25) NOT NULL COMMENT '券的编号',
   `user_id` int(11) DEFAULT '0'  COMMENT '订单id',
   `redpack_type` tinyint(1)  DEFAULT '1' COMMENT '类型{radio} (1:优惠券,2:线下凭证)', 
   `agent_sn`  varchar(25) NOT NULL  COMMENT '优惠券sn',
   `ticket_sn` varchar(25) DEFAULT NULL COMMENT '票务编号=线下凭证',
   `discount`  decimal(10,2) DEFAULT '0.00'  COMMENT '折扣金额' ,
   `is_used`   tinyint(1) unsigned DEFAULT '0' COMMENT '状态 {radio} (0:待用,1:已用)', 
   `use_time` datetime DEFAULT NULL COMMENT '使用时间{date}(datetime)',
   `end_time`  datetime DEFAULT NULL COMMENT '结束时间{date}(datetime)',
   `sort` int(11) DEFAULT '0' COMMENT '排序',
    `status` tinyint(1) unsigned DEFAULT '1' COMMENT '状态 {radio} (0:禁用,1:启用)', 
    `create_time` int(11) DEFAULT NULL COMMENT '创建时间',
    `update_time` int(11) DEFAULT NULL COMMENT '更新时间',
    `delete_time` int(11) DEFAULT NULL COMMENT '删除时间', 
  PRIMARY KEY (`id`),
  unique `user_id` (`user_id`,`redpack_no`) 
) ENGINE=InnoDB DEFAULT CHARSET=utf8  COMMENT='优惠券领取记录表';

CREATE TABLE IF NOT EXISTS `ims_knscy_comment` (
  `id` int(12) NOT NULL AUTO_INCREMENT,
   `uniacid` int(12) DEFAULT NULL,
   `nickname` varchar(25) NOT NULL COMMENT '点评人',
   `user_id` int(11) DEFAULT '0'  COMMENT '用户id',
   `avatar` varchar(255)  DEFAULT '' COMMENT '头像{image}', 
   `score`  int(6) DEFAULT '0'   COMMENT '评价分数', 
   `zan`  int(11) DEFAULT '0'   COMMENT '点赞数',
   `content` varchar(255) DEFAULT ''  COMMENT '评论内容' ,
   `thumbs`  text DEFAULT NULL  COMMENT '图片{images}' , 
    `sort` int(11) DEFAULT '0' COMMENT '排序',
    `status` tinyint(1) unsigned DEFAULT '1' COMMENT '状态 {radio} (0:禁用,1:启用)', 
    `create_time` int(11) DEFAULT NULL COMMENT '创建时间',
    `update_time` int(11) DEFAULT NULL COMMENT '更新时间',
    `delete_time` int(11) DEFAULT NULL COMMENT '删除时间', 
  PRIMARY KEY (`id`),
  key `user_id` (`user_id`) 
) ENGINE=InnoDB DEFAULT CHARSET=utf8  COMMENT='游客点评';

  CREATE TABLE IF NOT EXISTS `ims_knscy_activity` (
    `id` int(11) NOT NULL   AUTO_INCREMENT  COMMENT 'ID', 
    `uniacid` int(11) DEFAULT '0' COMMENT '公众号id', 
    `title` varchar(255)  NOT NULL  COMMENT '标题名称', 
    `sub_title` varchar(255)  NOT NULL  COMMENT '副标题', 
    `cover` varchar(255) DEFAULT NULL COMMENT '图片 {image}', 
    `content` longtext DEFAULT NULL COMMENT '内容',
    `total_nums` int(11) DEFAULT '0' COMMENT '总报名人数',  
    `start_time` datetime DEFAULT NULL COMMENT '开始时间{date}(datetime)',
    `end_time`  datetime DEFAULT NULL COMMENT '结束时间{date}(datetime)',  
    `sort` int(11) DEFAULT '0' COMMENT '排序',
    `status` tinyint(1) unsigned DEFAULT '1' COMMENT '状态 {radio} (0:禁用,1:启用)',
    `create_time` int(11) DEFAULT NULL COMMENT '创建时间',
    `update_time` int(11) DEFAULT NULL COMMENT '更新时间',
    `delete_time` int(11) DEFAULT NULL COMMENT '删除时间',
    PRIMARY KEY (`id`) ,
    KEY `uniacid` (`uniacid`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8  COMMENT='活动报名主题';
  
CREATE TABLE IF NOT EXISTS `ims_knscy_activity_logs` (
   `id` int(12) NOT NULL AUTO_INCREMENT,
   `uniacid` int(12) DEFAULT NULL, 
   `activity_id` int(11) DEFAULT '0'  COMMENT '活动id',
    `user_id` int(11) DEFAULT '0'  COMMENT '用户id',
    `tag`  varchar(45) DEFAULT NULL  COMMENT '标示' ,
    `content` text,
    `sort` int(11) DEFAULT '0' COMMENT '排序',
    `status` tinyint(1) unsigned DEFAULT '1' COMMENT '状态 {radio} (0:禁用,1:启用)',
    `create_time` int(11) DEFAULT NULL COMMENT '创建时间',
    `update_time` int(11) DEFAULT NULL COMMENT '更新时间',
    `delete_time` int(11) DEFAULT NULL COMMENT '删除时间', 
  PRIMARY KEY (`id`),
  key `activity_id` (`activity_id`),
  key `user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8  COMMENT='用户报名活动表';

CREATE TABLE IF NOT EXISTS `ims_knscy_message` (
`id` int(12) NOT NULL AUTO_INCREMENT,
`uniacid` int(12) DEFAULT NULL,  
`user_id` int(11) DEFAULT '0'  COMMENT '用户id',
`tag`  varchar(45) DEFAULT NULL  COMMENT '标示' ,
`link_url`  varchar(255) DEFAULT NULL  COMMENT '详情链接' ,
`content` text,
`sort` int(11) DEFAULT '0' COMMENT '排序',
`status` tinyint(1) unsigned DEFAULT '1' COMMENT '状态 {radio} (0:禁用,1:启用)',
`create_time` int(11) DEFAULT NULL COMMENT '创建时间',
`update_time` int(11) DEFAULT NULL COMMENT '更新时间',
`delete_time` int(11) DEFAULT NULL COMMENT '删除时间', 
PRIMARY KEY (`id`),
key `uniacid` (`uniacid`),
key `user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8  COMMENT='用户站内消息';

EOT;

pdo_run($sql);
